/*
 * @Author       : Hejh(3010733382@qq.com)
 * @Version      : V1.0
 * @Date         : 2024-01-30 11:01:15
 * @Description  : 错题相关接口
 */

import type {
  ErrorQuestionCreateReq,
  ErrorQuestionPageRes,
  ErrorPaperRes,
  ErrorQuestionReq,
  ErrorQuestionUpdateReq,
  ErrorPaperReq
} from '@/types/errorQuestion'
import request from '@/utils/request'

// 分页查询错题接口
export const getErrorQuestionByPage = (params?: ErrorQuestionReq) => {
  return request.get<ErrorQuestionPageRes>('/errorQuestion/list', { params })
}

// 分页查询错题试卷接口
export const getErrorPaperByPage = (params?: ErrorPaperReq) => {
  return request.get<ErrorPaperRes>('/errorQuestion/paperList', { params })
}

// 分页查询错题接口
export const getAuthErrorQuestionByPage = (params?: ErrorQuestionReq) => {
  return request.get<ErrorQuestionPageRes>('/errorQuestion/auth/list', { params })
}

// 添加错题接口
export const createErrorQuestion = (data: ErrorQuestionCreateReq) => {
  return request.post('/errorQuestion/create', data)
}

// 更新错题接口
export const updateErrorQuestion = (data: ErrorQuestionUpdateReq) => {
  return request.put('/errorQuestion/update', data)
}

// 错题排序接口
export const sortErrorQuestion = (errorQuestionIds: string[]) => {
  return request.put('/errorQuestion/sort', { errorQuestionIds })
}

// 错题删除接口
export const delErrorQuestion = (errorQuestionIds: string[], picCode?: string) => {
  return request.delete('/errorQuestion/delete', { data: { errorQuestionIds, picCode } })
}
